/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
/* Generated By:JavaCC: Do not edit this line. CLangParser.java */
// Begin CLangParser

package robocup.parser9;

import robocup.component.ControllerNumbers.PLAY_MODE;
import robocup.component.ControllerNumbers;
import robocup.component.AbstractAgent;
import robocup.component.infotypes.Info;
import robocup.component.infotypes.OLCoachSayInfo;
import robocup.component.speechacts.coachlanguage.*;
import java.io.StringReader;


/**
 * Robocup clang Parser<br><br>
 * This parser is repsonsible for building the CLang-Tree out of the
 * given clang messages. This class is 
 * created by the javacc parser generator. Therefore do not change this class 
 * directly, but change the CLangParser.jj and regenerate the code afterwards.
 * <br><br>
 * Notice: Please ignore the following warnings from Java Compiler Compiler...
 * Warning: Choice conflict involving two expansions at
 *        line 1039, column 3 and line 1045, column 4 respectively.
 *        A common prefix is: "("
 *        Consider using a lookahead of 2 for earlier expansion.<br>
 * Warning: Choice conflict involving two expansions at
 *        line 1051, column 4 and line 1057, column 3 respectively.
 *        A common prefix is: "("
 *        Consider using a lookahead of 2 for earlier expansion.<br><br>
 *
 * These two warnings are already solved by LOOKAHEAD.
 */
public class CLangParser implements CLangParserConstants {

  /**
   * An info for online coach-messages.
   */
  OLCoachSayInfo olcsi;

  /**
   * The message to parse.
   */
  String cmd;

  /**
   * A reference to the agent, which contains this parser.
   */
  AbstractAgent ra;

        /**
	 * Creates a new instance of the parser.
	 * @param - StringReader - reader for accessing strings
	 * @param - AbstractAgent - the agent object containing this parser
	 */
  public CLangParser(StringReader str, AbstractAgent ra){
    this (str);
    this .ra = ra;
  }

  /**
   * This method parses the given message into a usable
   * info-object.
   * @param - the message to parse
   * @return - the corresponding info-object.
   */
  public Info parseCoach(String cmd)throws ParseException{
    ReInit(new StringReader(cmd));
    this .cmd = cmd;
    try {
      hearCoach();
    }
    catch (ParseException e){
      System.out.println("Exception during Parsing with Command:");
      System.out.println("  "+cmd+"\r\n"+e);
    }
    return olcsi;
  }

  final public void hearCoach() throws ParseException {
  Token iCycle;
  boolean eastCoach;
    switch (jj_nt.kind) {
    case NUM:
      iCycle = jj_consume_token(NUM);
      switch (jj_nt.kind) {
      case OLCOACHR:
        jj_consume_token(OLCOACHR);
    eastCoach = true;
        break;
      case OLCOACHL:
        jj_consume_token(OLCOACHL);
    eastCoach = false;
        break;
      default:
        jj_la1[0] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    olcsi = new OLCoachSayInfo(Integer.parseInt(iCycle.image));
    if ((ra.isTeamEast()) && (eastCoach))olcsi.setSide(ControllerNumbers.TEAM.WE);
    if ((ra.isTeamEast()) && (!eastCoach))olcsi.setSide(ControllerNumbers.TEAM.OPPONENT);
    if ((!ra.isTeamEast()) && (eastCoach))olcsi.setSide(ControllerNumbers.TEAM.OPPONENT);
    if ((!ra.isTeamEast()) && (!eastCoach))olcsi.setSide(ControllerNumbers.TEAM.WE);
      startCLang();
      break;
    case OB:
      jj_consume_token(OB);
      jj_consume_token(SAY);
        olcsi = new OLCoachSayInfo(-1);
      startCLang();
      jj_consume_token(CB);
      break;
    default:
      jj_la1[1] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    jj_consume_token(0);
  }

  final public void startCLang() throws ParseException {
    jj_consume_token(OB);
    switch (jj_nt.kind) {
    case FREEFORM:
      jj_consume_token(FREEFORM);
      startFreeform();
      break;
    case DEFINE:
      jj_consume_token(DEFINE);
      label_1:
      while (true) {
        startDefine();
        switch (jj_nt.kind) {
        case OB:
          ;
          break;
        default:
          jj_la1[2] = jj_gen;
          break label_1;
        }
      }
      break;
    case RULE:
      jj_consume_token(RULE);
      startRuleMess();
      break;
    case ADVICE:
      jj_consume_token(ADVICE);
      startAdvice();
      break;
    case INFO:
      jj_consume_token(INFO);
      startInfo();
      break;
    case META:
      jj_consume_token(META);
      startMeta();
      break;
    case DELETE:
      jj_consume_token(DELETE);
      startDelete();
      break;
    case UNSUPPORTED_CLANG:
      jj_consume_token(UNSUPPORTED_CLANG);
   System.out.println("Error, unsupported Clang! (CLangParser)");
      break;
    default:
      jj_la1[3] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    jj_consume_token(CB);
  }

  final public void startFreeform() throws ParseException {
  Token msg;
    msg = jj_consume_token(STRING);
    olcsi.setFreeformMessage(msg.image);
  }

  final public void startDefine() throws ParseException {
  DefineMessage defineMessage;
    defineMessage = new DefineMessage();
    olcsi.addDefine(defineMessage);
    jj_consume_token(OB);
    switch (jj_nt.kind) {
    case DEFINEC:
      jj_consume_token(DEFINEC);
      startDefinec(defineMessage);
      break;
    case DEFINEA:
      jj_consume_token(DEFINEA);
      startDefinea(defineMessage);
      break;
    case DEFINED:
      jj_consume_token(DEFINED);
      startDefined(defineMessage);
      break;
    case DEFINER:
      jj_consume_token(DEFINER);
      startDefiner(defineMessage);
      break;
    case DEFINERSET:
      jj_consume_token(DEFINERSET);
      startDefinerset(defineMessage);
      break;
    case DEFINERULE:
      jj_consume_token(DEFINERULE);
      startDefineRule(defineMessage);
      break;
    default:
      jj_la1[4] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    jj_consume_token(CB);
  }

  final public void startRuleMess() throws ParseException {
  ActivationElement activationElement;
  RuleMessage ruleMessage;
  IdList ruleList;
    ruleMessage = new RuleMessage();
    olcsi.setRuleMessage(ruleMessage);
    label_2:
    while (true) {
    activationElement = new ActivationElement();
    ruleMessage.addActivationElement(activationElement);
    ruleList = new IdList();
    activationElement.setRuleList(ruleList);
      jj_consume_token(OB);
      switch (jj_nt.kind) {
      case ON:
        jj_consume_token(ON);
    activationElement.setRuleOn(true);
        break;
      case OFF:
        jj_consume_token(OFF);
    activationElement.setRuleOn(false);
        break;
      default:
        jj_la1[5] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      idList(ruleList);
      jj_consume_token(CB);
      switch (jj_nt.kind) {
      case OB:
        ;
        break;
      default:
        jj_la1[6] = jj_gen;
        break label_2;
      }
    }
  }

  final public void startInfo() throws ParseException {
        InfoMessage infoMessage;
        Tok tok;
                infoMessage = new InfoMessage();
                olcsi.setInfoMessage(infoMessage);
    label_3:
    while (true) {
                tok = new Tok();
                infoMessage.addTok(tok);
      tok(tok);
      switch (jj_nt.kind) {
      case OB:
        ;
        break;
      default:
        jj_la1[7] = jj_gen;
        break label_3;
      }
    }
  }

  final public void startAdvice() throws ParseException {
        AdviceMessage adviceMessage;
        Tok tok;
                adviceMessage = new AdviceMessage();
                olcsi.setAdviceMessage(adviceMessage);
    label_4:
    while (true) {
                tok = new Tok();
                adviceMessage.addTok(tok);
      tok(tok);
      switch (jj_nt.kind) {
      case OB:
        ;
        break;
      default:
        jj_la1[8] = jj_gen;
        break label_4;
      }
    }
  }

  final public void tok(Tok tok) throws ParseException {
        Token id;
        Condition condition;
        Directive directive;
    jj_consume_token(OB);
    switch (jj_nt.kind) {
    case CLEAR:
      jj_consume_token(CLEAR);
                tok.setClear(true);
      break;
    case NUM:
      id = jj_consume_token(NUM);
                tok.setId(Integer.parseInt(id.image));
                condition = new Condition();
                tok.setCondition(condition);
      condition(condition);
      label_5:
      while (true) {
                directive = new Directive();
                tok.addDirective(directive);
        directive(directive);
        switch (jj_nt.kind) {
        case OB:
        case STR:
          ;
          break;
        default:
          jj_la1[9] = jj_gen;
          break label_5;
        }
      }
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    jj_consume_token(CB);
  }

  final public void startMeta() throws ParseException {
        Token id;
        MetaMessage metaMessage;
        metaMessage = new MetaMessage();
            olcsi.setMetaMessage(metaMessage);
    label_6:
    while (true) {
      jj_consume_token(OB);
      jj_consume_token(VER);
      id = jj_consume_token(NUM);
                metaMessage.addVer(Double.parseDouble(id.image));
      jj_consume_token(CB);
      switch (jj_nt.kind) {
      case OB:
        ;
        break;
      default:
        jj_la1[11] = jj_gen;
        break label_6;
      }
    }
  }

  final public void startDelete() throws ParseException {
  DeleteMessage deleteMessage;
  IdList ruleList;
    deleteMessage = new DeleteMessage();
    olcsi.setDeleteMessage(deleteMessage);
    ruleList = new IdList();
    deleteMessage.setDeleteList(ruleList);
    idList(ruleList);
  }

  final public void idList(IdList idList) throws ParseException {
  Token token;
    switch (jj_nt.kind) {
    case VAR:
      token = jj_consume_token(VAR);
    idList.addId(token.image);
      break;
    case ALL:
      token = jj_consume_token(ALL);
    idList.addId(token.image);
      break;
    case OB:
      jj_consume_token(OB);
      label_7:
      while (true) {
        idList2(idList);
        switch (jj_nt.kind) {
        case VAR:
          ;
          break;
        default:
          jj_la1[12] = jj_gen;
          break label_7;
        }
      }
      jj_consume_token(CB);
      break;
    default:
      jj_la1[13] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void idList2(IdList idList) throws ParseException {
  Token token;
    token = jj_consume_token(VAR);
    idList.addId(token.image);
  }

  final public void startDefinerset(DefineMessage defineMessage) throws ParseException {
  Definerset definerset;
  Token str;
  Token id;
    definerset = new Definerset();
    defineMessage.setDefinerset(definerset);
    str = jj_consume_token(STR);
    definerset.setName(str.image);
    label_8:
    while (true) {
      id = jj_consume_token(NUM);
        definerset.addId(Integer.parseInt(id.image));
      switch (jj_nt.kind) {
      case NUM:
        ;
        break;
      default:
        jj_la1[14] = jj_gen;
        break label_8;
      }
    }
  }

  final public void startDefinec(DefineMessage defineMessage) throws ParseException {
  DefineCondition defineCondition;
  Condition condition;
  Token str;
    defineCondition = new DefineCondition();
    defineMessage.setDefineCondition(defineCondition);
    condition = new Condition();
    defineCondition.setCondition(condition);
    str = jj_consume_token(STR);
    defineCondition.setConditionName(str.image);
    condition(condition);
  }

  final public void startDefinea(DefineMessage defineMessage) throws ParseException {
  DefineAction defineAction;
  ActionElement action;
  Token str;
    defineAction = new DefineAction();
    defineMessage.setDefineAction(defineAction);
    action = new ActionElement();
    defineAction.setAction(action);
    str = jj_consume_token(STR);
    defineAction.setActionName(str.image);
    action(action);
  }

  final public void startDefined(DefineMessage defineMessage) throws ParseException {
  DefineDirective defineDirective;
  Directive directive;
  Token str;
    defineDirective = new DefineDirective();
    defineMessage.setDefineDirective(defineDirective);
    directive = new Directive();
    defineDirective.setDirective(directive);
    str = jj_consume_token(STR);
    defineDirective.setDirectiveName(str.image);
    directive(directive);
  }

  final public void startDefiner(DefineMessage defineMessage) throws ParseException {
  DefineRegion defineRegion;
  Region reg;
  Token str;
    defineRegion = new DefineRegion();
    defineMessage.setDefineRegion(defineRegion);
    reg = new Region();
    defineRegion.setRegion(reg);
    str = jj_consume_token(STR);
    defineRegion.setRegionName(str.image);
    region(reg);
  }

  final public void startDefineRule(DefineMessage defineMessage) throws ParseException {
  Token clang;
  DefineRule defineRule;
  Rule rule;
    defineRule = new DefineRule();
    defineMessage.setDefineRule(defineRule);
    rule = new Rule();
    defineRule.setRule(rule);
    clang = jj_consume_token(VAR);
    defineRule.setRuleName(clang.image);
    switch (jj_nt.kind) {
    case MODEL:
      jj_consume_token(MODEL);
    defineRule.setDirec(false);
      break;
    case DIREC:
      jj_consume_token(DIREC);
    defineRule.setDirec(true);
      break;
    default:
      jj_la1[15] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    rule(rule);
  }

  final public void condition(Condition condition) throws ParseException {
  Token clangStr;
  Condition con;
    switch (jj_nt.kind) {
    case OB:
      jj_consume_token(OB);
      switch (jj_nt.kind) {
      case FALSE:
        jj_consume_token(FALSE);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.FALSE);
        break;
      case TRUE:
        jj_consume_token(TRUE);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.TRUE);
        break;
      case PLAYM:
        jj_consume_token(PLAYM);
        playMode(condition);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.PLAYM);
        break;
      case UNUM:
        jj_consume_token(UNUM);
        unum(condition);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.UNUM);
        break;
      case BOWNER:
        jj_consume_token(BOWNER);
        bowner(condition);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.BOWNER);
        break;
      case BPOS:
        jj_consume_token(BPOS);
        bpos(condition);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.BPOS);
        break;
      case PPOS:
        jj_consume_token(PPOS);
        ppos(condition);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.PPOS);
        break;
      case TIME:
      case OPP_GOALS:
      case OUR_GOALS:
      case GOAL_DIFF:
      case NUM:
        condComp(condition);
        condition.setConditionType(TypeConstants.CONDITIONTYPE.CONDCOMP);
        break;
      case NOT:
        jj_consume_token(NOT);
        condition.setConditionType(TypeConstants.CONDITIONTYPE.NOT);
    con = new Condition();
    condition.setNot(con);
        condition(con);
        break;
      case AND:
        jj_consume_token(AND);
        label_9:
        while (true) {
        condition.setConditionType(TypeConstants.CONDITIONTYPE.AND);
    con = new Condition();
    condition.addAnd(con);
          condition(con);
          switch (jj_nt.kind) {
          case OB:
          case STR:
            ;
            break;
          default:
            jj_la1[16] = jj_gen;
            break label_9;
          }
        }
        break;
      case OR:
        jj_consume_token(OR);
        label_10:
        while (true) {
        condition.setConditionType(TypeConstants.CONDITIONTYPE.OR);
    con = new Condition();
    condition.addOr(con);
          condition(con);
          switch (jj_nt.kind) {
          case OB:
          case STR:
            ;
            break;
          default:
            jj_la1[17] = jj_gen;
            break label_10;
          }
        }
        break;
      default:
        jj_la1[18] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      jj_consume_token(CB);
      break;
    case STR:
      clangStr = jj_consume_token(STR);
    condition.setConditionType(TypeConstants.CONDITIONTYPE.NAME);
    condition.setClangStr(clangStr.image);
      break;
    default:
      jj_la1[19] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void unum(Condition condition) throws ParseException {
        Token unum;
        UnumSet unumSet;
    switch (jj_nt.kind) {
    case NUM:
      unum = jj_consume_token(NUM);
                condition.setUnumInt(Integer.parseInt(unum.image));
      break;
    case STR:
      unum = jj_consume_token(STR);
                condition.setUnumString(unum.image);
      break;
    case VAR:
      unum = jj_consume_token(VAR);
                condition.setUnumString(unum.image);
      break;
    default:
      jj_la1[20] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                unumSet = new UnumSet();
                condition.setUnumSet(unumSet);
    unumSet(unumSet);
  }

  final public void condComp(Condition condition) throws ParseException {
        Token comp;
        Token num;
    switch (jj_nt.kind) {
    case NUM:
      num = jj_consume_token(NUM);
      comp = jj_consume_token(COMP);
      switch (jj_nt.kind) {
      case TIME:
        jj_consume_token(TIME);
                                           condition.setCondCompType(TypeConstants.CONDCOMPTYPE.TIME);
        break;
      case OPP_GOALS:
        jj_consume_token(OPP_GOALS);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.OPP_GOALS);
        break;
      case OUR_GOALS:
        jj_consume_token(OUR_GOALS);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.OUR_GOALS);
        break;
      case GOAL_DIFF:
        jj_consume_token(GOAL_DIFF);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.GOAL_DIFF);
        break;
      default:
        jj_la1[21] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      break;
    case TIME:
    case OPP_GOALS:
    case OUR_GOALS:
    case GOAL_DIFF:
      switch (jj_nt.kind) {
      case TIME:
        jj_consume_token(TIME);
                 condition.setCondCompType(TypeConstants.CONDCOMPTYPE.TIME);
        break;
      case OPP_GOALS:
        jj_consume_token(OPP_GOALS);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.OPP_GOALS);
        break;
      case OUR_GOALS:
        jj_consume_token(OUR_GOALS);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.OUR_GOALS);
        break;
      case GOAL_DIFF:
        jj_consume_token(GOAL_DIFF);
                     condition.setCondCompType(TypeConstants.CONDCOMPTYPE.GOAL_DIFF);
        break;
      default:
        jj_la1[22] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      comp = jj_consume_token(COMP);
      num = jj_consume_token(NUM);
      break;
    default:
      jj_la1[23] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
                condition.setCondComp(comp.image);
                condition.setCondCompInt(Integer.parseInt(num.image));
  }

  final public void ppos(Condition condition) throws ParseException {
  UnumSet uSet;
  Region reg;
  Token ppos1;
  Token ppos2;
    uSet = new UnumSet();
    condition.setUnumSet(uSet);
    reg = new Region();
    condition.setRegion(reg);
    switch (jj_nt.kind) {
    case OUR:
      jj_consume_token(OUR);
    condition.setTeamOur(true);
      break;
    case OPP:
      jj_consume_token(OPP);
    condition.setTeamOur(false);
      break;
    default:
      jj_la1[24] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    unumSet(uSet);
    ppos1 = jj_consume_token(NUM);
    condition.setPposInt1(Integer.parseInt(ppos1.image));
    ppos2 = jj_consume_token(NUM);
    condition.setPposInt2(Integer.parseInt(ppos2.image));
    region(reg);
  }

  final public void bpos(Condition condition) throws ParseException {
  Region reg;
    reg = new Region();
    condition.setRegion(reg);
    region(reg);
  }

  final public void region(Region region) throws ParseException {
  Token clang;
  Token a1;
  Token a2;
  Token a3;
  Token a4;
  CPoint pt;
  CPoint rpt1;
  CPoint rpt2;
  CPoint tpt1;
  CPoint tpt2;
  CPoint tpt3;
  CPoint tpt4;
  CPoint apt;
  Region reg;
    switch (jj_nt.kind) {
    case OB:
      jj_consume_token(OB);
      switch (jj_nt.kind) {
      case NULL:
        jj_consume_token(NULL);
    region.setNull();
        break;
      case REC:
        jj_consume_token(REC);
    rpt1 = new CPoint();
    region.setRecPoint1(rpt1);
    rpt2 = new CPoint();
    region.setRecPoint2(rpt2);
        jj_consume_token(OB);
        point(rpt1);
        jj_consume_token(CB);
        jj_consume_token(OB);
        point(rpt2);
        jj_consume_token(CB);
        break;
      case PT:
      case OB:
    pt = new CPoint();
    region.setPoint(pt);
        point(pt);
        break;
      case TRI:
        jj_consume_token(TRI);
    tpt1 = new CPoint();
    region.setTriPoint1(tpt1);
    tpt2 = new CPoint();
    region.setTriPoint2(tpt2);
    tpt3 = new CPoint();
    region.setTriPoint3(tpt3);
        jj_consume_token(OB);
        point(tpt1);
        jj_consume_token(CB);
        jj_consume_token(OB);
        point(tpt2);
        jj_consume_token(CB);
        jj_consume_token(OB);
        point(tpt3);
        jj_consume_token(CB);
        break;
      case QUAD:
        jj_consume_token(QUAD);
           //WARNING!! When coach is defining a quad the last point gets lost through the server!
    tpt1 = new CPoint();
    region.setQuadPoint1(tpt1);
    tpt2 = new CPoint();
    region.setQuadPoint2(tpt2);
    tpt3 = new CPoint();
    region.setQuadPoint3(tpt3);
    tpt4 = new CPoint();
    region.setQuadPoint4(tpt4);
        jj_consume_token(OB);
        point(tpt1);
        jj_consume_token(CB);
        jj_consume_token(OB);
        point(tpt2);
        jj_consume_token(CB);
        jj_consume_token(OB);
        point(tpt3);
        jj_consume_token(CB);
        break;
      case REG:
        jj_consume_token(REG);
        label_11:
        while (true) {
    reg = new Region();
    region.addRegion(reg);
          region(reg);
          switch (jj_nt.kind) {
          case OB:
          case STR:
            ;
            break;
          default:
            jj_la1[25] = jj_gen;
            break label_11;
          }
        }
        break;
      case ARC:
        jj_consume_token(ARC);
    apt = new CPoint();
    region.setArcPoint(apt);
        jj_consume_token(OB);
        point(apt);
        jj_consume_token(CB);
        a1 = jj_consume_token(NUM);
        a2 = jj_consume_token(NUM);
        a3 = jj_consume_token(NUM);
        a4 = jj_consume_token(NUM);
    region.setArcReal1(Double.parseDouble(a1.image));
    region.setArcReal2(Double.parseDouble(a2.image));
    region.setArcReal3(Double.parseDouble(a3.image));
    region.setArcReal4(Double.parseDouble(a4.image));
        break;
      default:
        jj_la1[26] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      jj_consume_token(CB);
      break;
    case STR:
      clang = jj_consume_token(STR);
    region.setRegionName(clang.image);
      break;
    default:
      jj_la1[27] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void point(CPoint pt) throws ParseException {
  CPoint npt;
  PointArith pa;
  Token unum;
  Token x;
  Token y;
    switch (jj_nt.kind) {
    case PT:
      jj_consume_token(PT);
      switch (jj_nt.kind) {
      case BALL:
        jj_consume_token(BALL);
    pt.setBall();
        break;
      case NUM:
        x = jj_consume_token(NUM);
        y = jj_consume_token(NUM);
    pt.setX(Double.parseDouble(x.image));
    pt.setY(Double.parseDouble(y.image));
        switch (jj_nt.kind) {
        case OB:
                npt = new CPoint();
                pt.setPoint(npt);
          jj_consume_token(OB);
          point(npt);
          jj_consume_token(CB);
          break;
        default:
          jj_la1[28] = jj_gen;
          ;
        }
        break;
      case OPP:
      case OUR:
        switch (jj_nt.kind) {
        case OUR:
          jj_consume_token(OUR);
    pt.setTeamOur(true);
          break;
        case OPP:
          jj_consume_token(OPP);
    pt.setTeamOur(false);
          break;
        default:
          jj_la1[29] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        switch (jj_nt.kind) {
        case NUM:
          unum = jj_consume_token(NUM);
    pt.setUnumInt(Integer.parseInt(unum.image));
          break;
        case VAR:
          unum = jj_consume_token(VAR);
    pt.setUnumString(unum.image);
          break;
        case STR:
          unum = jj_consume_token(STR);
    pt.setUnumString(unum.image);
          break;
        default:
          jj_la1[30] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      default:
        jj_la1[31] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      break;
    case OB:
        pa = new PointArith();
        pt.setPointArith(pa);
      pointArith(pa);
      break;
    default:
      jj_la1[32] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void pointArith(PointArith pointArith) throws ParseException {
        PointArith pal;
                pal = new PointArith();
                pointArith.setPointArithLeft(pal);
    pointArith1(pal);
  }

  final public void pointArith1(PointArith pointArith) throws ParseException {
        Token op;
        PointArith pal;
        PointArith par;
                pal = new PointArith();
                pointArith.setPointArithLeft(pal);
    pointArith2(pal);
    switch (jj_nt.kind) {
    case SUM:
    case DIF:
    case MUL:
    case DIV:
      switch (jj_nt.kind) {
      case MUL:
        op = jj_consume_token(MUL);
        break;
      case SUM:
        op = jj_consume_token(SUM);
        break;
      case DIF:
        op = jj_consume_token(DIF);
        break;
      case DIV:
        op = jj_consume_token(DIV);
        break;
      default:
        jj_la1[33] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                pointArith.setOp(op.image);
                par = new PointArith();
                pointArith.setPointArithRight(par);
      pointArith1(par);
      break;
    default:
      jj_la1[34] = jj_gen;
      ;
    }
  }

  final public void pointArith2(PointArith pointArith) throws ParseException {
        CPoint pt;
                pt = new CPoint();
                pointArith.setPoint(pt);
    jj_consume_token(OB);
    point(pt);
    jj_consume_token(CB);
  }

  final public void bowner(Condition condition) throws ParseException {
  UnumSet unumSet;
    unumSet = new UnumSet();
    condition.setUnumSet(unumSet);
    switch (jj_nt.kind) {
    case OUR:
      jj_consume_token(OUR);
    condition.setTeamOur(true);
      break;
    case OPP:
      jj_consume_token(OPP);
    condition.setTeamOur(false);
      break;
    default:
      jj_la1[35] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    unumSet(unumSet);
  }

  final public void unumSet(UnumSet unumSet) throws ParseException {
  Token unum;
    jj_consume_token(OG);
    label_12:
    while (true) {
      switch (jj_nt.kind) {
      case NUM:
        unum = jj_consume_token(NUM);
    unumSet.addInteger(Integer.parseInt(unum.image));
        break;
      case VAR:
        unum = jj_consume_token(VAR);
    unumSet.addString(unum.image);
        break;
      case STR:
        unum = jj_consume_token(STR);
    unumSet.addString(unum.image);
        break;
      default:
        jj_la1[36] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      switch (jj_nt.kind) {
      case STR:
      case VAR:
      case NUM:
        ;
        break;
      default:
        jj_la1[37] = jj_gen;
        break label_12;
      }
    }
    jj_consume_token(CG);
  }

  final public void action(ActionElement action) throws ParseException {
  Token token;
  Region reg;
  UnumSet uSet;
  Bto bto;
    switch (jj_nt.kind) {
    case OB:
      jj_consume_token(OB);
      switch (jj_nt.kind) {
      case POS:
        jj_consume_token(POS);
    action.setActionType(TypeConstants.ACTIONTYPE.POS);
    reg = new Region();
    action.setPosRegion(reg);
        region(reg);
        break;
      case HOME:
        jj_consume_token(HOME);
    action.setActionType(TypeConstants.ACTIONTYPE.HOME);
    reg = new Region();
    action.setHomeRegion(reg);
        region(reg);
        break;
      case MARK:
        jj_consume_token(MARK);
    action.setActionType(TypeConstants.ACTIONTYPE.MARK);
    uSet = new UnumSet();
    action.setMarkUnumSet(uSet);
        unumSet(uSet);
        break;
      case MARKL:
        jj_consume_token(MARKL);
        switch (jj_nt.kind) {
        case OB:
        case STR:
    action.setActionType(TypeConstants.ACTIONTYPE.MARKL_REGION);
    reg = new Region();
    action.setMarklRegion(reg);
          region(reg);
          break;
        case OG:
    action.setActionType(TypeConstants.ACTIONTYPE.MARKL_UNUM);
    uSet = new UnumSet();
    action.setMarklUnumSet(uSet);
          unumSet(uSet);
          break;
        default:
          jj_la1[38] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      case OLINE:
        jj_consume_token(OLINE);
    action.setActionType(TypeConstants.ACTIONTYPE.OLINE);
    reg = new Region();
    action.setOlineRegion(reg);
        region(reg);
        break;
      case HTYPE:
        jj_consume_token(HTYPE);
        token = jj_consume_token(NUM);
    action.setActionType(TypeConstants.ACTIONTYPE.HTYPE);
    action.setHtypeInt(Integer.parseInt(token.image));
        break;
      case PASS:
        jj_consume_token(PASS);
        switch (jj_nt.kind) {
        case OB:
        case STR:
    action.setActionType(TypeConstants.ACTIONTYPE.PASS_REGION);
    reg = new Region();
    action.setPassRegion(reg);
          region(reg);
          break;
        case OG:
    action.setActionType(TypeConstants.ACTIONTYPE.PASS_UNUM);
    uSet = new UnumSet();
    action.setPassUnumSet(uSet);
          unumSet(uSet);
          break;
        default:
          jj_la1[39] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        break;
      case DRIBBLE:
        jj_consume_token(DRIBBLE);
    action.setActionType(TypeConstants.ACTIONTYPE.DRIBBLE);
    reg = new Region();
    action.setDribbleRegion(reg);
        region(reg);
        break;
      case CLEAR:
        jj_consume_token(CLEAR);
    action.setActionType(TypeConstants.ACTIONTYPE.CLEAR);
    reg = new Region();
    action.setClearRegion(reg);
        region(reg);
        break;
      case SHOOT:
        jj_consume_token(SHOOT);
    action.setActionType(TypeConstants.ACTIONTYPE.SHOOT);
        break;
      case HOLD:
        jj_consume_token(HOLD);
    action.setActionType(TypeConstants.ACTIONTYPE.HOLD);
        break;
      case INTERCEPT:
        jj_consume_token(INTERCEPT);
    action.setActionType(TypeConstants.ACTIONTYPE.INTERCEPT);
        break;
      case APPROACH_BALL:
        jj_consume_token(APPROACH_BALL);
        action.setActionType(TypeConstants.ACTIONTYPE.APPROACH_BALL);
        break;
      case BTO:
        jj_consume_token(BTO);
    action.setActionType(TypeConstants.ACTIONTYPE.BTO);
    bto = new Bto();
    action.setBto(bto);
        bto(bto);
        break;
      case TACKLE:
        jj_consume_token(TACKLE);
    action.setActionType(TypeConstants.ACTIONTYPE.TACKLE);
    uSet = new UnumSet();
    action.setMarkUnumSet(uSet);
        unumSet(uSet);
        break;
      default:
        jj_la1[40] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      jj_consume_token(CB);
      break;
    case STR:
      token = jj_consume_token(STR);
    action.setActionType(TypeConstants.ACTIONTYPE.NAME);
    action.setActionName(token.image);
      break;
    default:
      jj_la1[41] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void bto(Bto bto) throws ParseException {
        UnumSet unumSet;
        Region region;
        BmoveSet bmoveSet;
    switch (jj_nt.kind) {
    case OG:
                unumSet = new UnumSet();
                bto.setUnumSet(unumSet);
      unumSet(unumSet);
      break;
    case OB:
    case STR:
                region = new Region();
                bto.setRegion(region);
      region(region);
                bmoveSet = new BmoveSet();
                bto.setBmoveSet(bmoveSet);
      bmoveSet(bmoveSet);
      break;
    default:
      jj_la1[42] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void bmoveSet(BmoveSet bmoveSet) throws ParseException {
  Token bmove;
    jj_consume_token(OG);
    label_13:
    while (true) {
      bmove = jj_consume_token(BMOVE);
    bmoveSet.addBmove(bmove.image);
      switch (jj_nt.kind) {
      case BMOVE:
        ;
        break;
      default:
        jj_la1[43] = jj_gen;
        break label_13;
      }
    }
    jj_consume_token(CG);
  }

  final public void directive(Directive directive) throws ParseException {
  ActionElement a;
  UnumSet uSet;
  Token clang;
    switch (jj_nt.kind) {
    case STR:
      clang = jj_consume_token(STR);
    directive.setClangStr(clang.image);
      break;
    case OB:
      jj_consume_token(OB);
      switch (jj_nt.kind) {
      case DO:
        jj_consume_token(DO);
    directive.setDoIt(true);
        break;
      case DONT:
        jj_consume_token(DONT);
    directive.setDoIt(false);
        break;
      default:
        jj_la1[44] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      switch (jj_nt.kind) {
      case OUR:
        jj_consume_token(OUR);
    directive.setTeamOur(true);
        break;
      case OPP:
        jj_consume_token(OPP);
    directive.setTeamOur(false);
        break;
      default:
        jj_la1[45] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    uSet = new UnumSet();
    directive.setUnumSet(uSet);
      unumSet(uSet);
      label_14:
      while (true) {
    a = new ActionElement();
    directive.addAction(a);
        action(a);
        switch (jj_nt.kind) {
        case OB:
        case STR:
          ;
          break;
        default:
          jj_la1[46] = jj_gen;
          break label_14;
        }
      }
      jj_consume_token(CB);
      break;
    default:
      jj_la1[47] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void playMode(Condition condition) throws ParseException {
    switch (jj_nt.kind) {
    case BKO:
      jj_consume_token(BKO);
    condition.setPlayMode(PLAY_MODE.BEFORE_KICK_OFF);
      break;
    case TIME_OVER:
      jj_consume_token(TIME_OVER);
    condition.setPlayMode(PLAY_MODE.TIME_OVER);
      break;
    case PLAY_ON:
      jj_consume_token(PLAY_ON);
    condition.setPlayMode(PLAY_MODE.PLAY_ON);
      break;
    case KO_OUR:
      jj_consume_token(KO_OUR);
    condition.setPlayMode(PLAY_MODE.KICK_OFF_OWN);
      break;
    case KO_OPP:
      jj_consume_token(KO_OPP);
    condition.setPlayMode(PLAY_MODE.KICK_OFF_OTHER);
      break;
    case KI_OUR:
      jj_consume_token(KI_OUR);
    condition.setPlayMode(PLAY_MODE.KICK_IN_OWN);
      break;
    case KI_OPP:
      jj_consume_token(KI_OPP);
    condition.setPlayMode(PLAY_MODE.KICK_IN_OTHER);
      break;
    case FK_OUR:
      jj_consume_token(FK_OUR);
    condition.setPlayMode(PLAY_MODE.FREE_KICK_OWN);
      break;
    case FK_OPP:
      jj_consume_token(FK_OPP);
    condition.setPlayMode(PLAY_MODE.FREE_KICK_OTHER);
      break;
    case CK_OUR:
      jj_consume_token(CK_OUR);
    condition.setPlayMode(PLAY_MODE.CORNER_KICK_OWN);
      break;
    case CK_OPP:
      jj_consume_token(CK_OPP);
    condition.setPlayMode(PLAY_MODE.CORNER_KICK_OTHER);
      break;
    case GK_OUR:
      jj_consume_token(GK_OUR);
    condition.setPlayMode(PLAY_MODE.GOAL_KICK_OWN);
      break;
    case GK_OPP:
      jj_consume_token(GK_OPP);
    condition.setPlayMode(PLAY_MODE.GOAL_KICK_OTHER);
      break;
    case GC_OUR:
      jj_consume_token(GC_OUR);
    condition.setPlayMode(PLAY_MODE.GOAL_OWN);
      break;
    case GC_OPP:
      jj_consume_token(GC_OPP);
    condition.setPlayMode(PLAY_MODE.GOAL_OTHER);
      break;
    case AG_OUR:
      jj_consume_token(AG_OUR);
    condition.setPlayMode(PLAY_MODE.UNKNOWN);
      break;
    case AG_OPP:
      jj_consume_token(AG_OPP);
    condition.setPlayMode(PLAY_MODE.UNKNOWN);
      break;
    default:
      jj_la1[48] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void rule(Rule rule) throws ParseException {
  Directive directiveElement;
  Rule ruleElement;
  Condition condition;
  IdList idList;
    if (jj_2_2(2)) {
    idList = new IdList();
    rule.setIdList(idList);
      idList(idList);
    } else {
      switch (jj_nt.kind) {
      case OB:
        jj_consume_token(OB);
    condition = new Condition();
    rule.setCondition(condition);
        condition(condition);
        if (jj_2_1(2)) {
          label_15:
          while (true) {
    directiveElement = new Directive();
    rule.addDirective(directiveElement);
            directive(directiveElement);
            switch (jj_nt.kind) {
            case OB:
            case STR:
              ;
              break;
            default:
              jj_la1[49] = jj_gen;
              break label_15;
            }
          }
        } else {
          switch (jj_nt.kind) {
          case ALL:
          case OB:
          case VAR:
            label_16:
            while (true) {
    ruleElement = new Rule();
    rule.addRule(ruleElement);
              rule(ruleElement);
              switch (jj_nt.kind) {
              case ALL:
              case OB:
              case VAR:
                ;
                break;
              default:
                jj_la1[50] = jj_gen;
                break label_16;
              }
            }
            break;
          default:
            jj_la1[51] = jj_gen;
            jj_consume_token(-1);
            throw new ParseException();
          }
        }
        jj_consume_token(CB);
        break;
      default:
        jj_la1[52] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    }
  }

  final private boolean jj_2_1(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_1(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(0, xla); }
  }

  final private boolean jj_2_2(int xla) {
    jj_la = xla; jj_lastpos = jj_scanpos = token;
    try { return !jj_3_2(); }
    catch(LookaheadSuccess ls) { return true; }
    finally { jj_save(1, xla); }
  }

  final private boolean jj_3R_27() {
    if (jj_scan_token(DONT)) return true;
    return false;
  }

  final private boolean jj_3R_25() {
    if (jj_3R_28()) return true;
    return false;
  }

  final private boolean jj_3_1() {
    Token xsp;
    if (jj_3R_17()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_17()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  final private boolean jj_3R_28() {
    if (jj_scan_token(VAR)) return true;
    return false;
  }

  final private boolean jj_3R_24() {
    if (jj_scan_token(OB)) return true;
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_26()) {
    jj_scanpos = xsp;
    if (jj_3R_27()) return true;
    }
    return false;
  }

  final private boolean jj_3R_22() {
    if (jj_scan_token(OB)) return true;
    Token xsp;
    if (jj_3R_25()) return true;
    while (true) {
      xsp = jj_scanpos;
      if (jj_3R_25()) { jj_scanpos = xsp; break; }
    }
    return false;
  }

  final private boolean jj_3R_23() {
    if (jj_scan_token(STR)) return true;
    return false;
  }

  final private boolean jj_3R_19() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_23()) {
    jj_scanpos = xsp;
    if (jj_3R_24()) return true;
    }
    return false;
  }

  final private boolean jj_3R_21() {
    if (jj_scan_token(ALL)) return true;
    return false;
  }

  final private boolean jj_3R_17() {
    if (jj_3R_19()) return true;
    return false;
  }

  final private boolean jj_3R_20() {
    if (jj_scan_token(VAR)) return true;
    return false;
  }

  final private boolean jj_3_2() {
    if (jj_3R_18()) return true;
    return false;
  }

  final private boolean jj_3R_18() {
    Token xsp;
    xsp = jj_scanpos;
    if (jj_3R_20()) {
    jj_scanpos = xsp;
    if (jj_3R_21()) {
    jj_scanpos = xsp;
    if (jj_3R_22()) return true;
    }
    }
    return false;
  }

  final private boolean jj_3R_26() {
    if (jj_scan_token(DO)) return true;
    return false;
  }

  public CLangParserTokenManager token_source;
  SimpleCharStream jj_input_stream;
  public Token token, jj_nt;
  private Token jj_scanpos, jj_lastpos;
  private int jj_la;
  public boolean lookingAhead = false;
  private boolean jj_semLA;
  private int jj_gen;
  final private int[] jj_la1 = new int[53];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static private int[] jj_la1_2;
  static private int[] jj_la1_3;
  static {
      jj_la1_0();
      jj_la1_1();
      jj_la1_2();
      jj_la1_3();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0xc00000,0x0,0x0,0xfb40,0x3f0000,0xc000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x3000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe0000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};
   }
   private static void jj_la1_1() {
      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xe7ff000,0x0,0x0,0xe400000,0xe400000,0xe400000,0x1800000,0x0,0x0,0x0,0x0,0x1800000,0x0,0x1800000,0x0,0x0,0x0,0x1800000,0x0,0x0,0x0,0x0,0xfff,0x0,0x0,0x0,0x0,0x1800000,0x0,0x0,0xf0000000,0x0,0x0,0x0,0x0,};
   }
   private static void jj_la1_2() {
      jj_la1_2 = new int[] {0x0,0x8000000,0x8000000,0x0,0x0,0x0,0x8000000,0x8000000,0x8000000,0x8000000,0x0,0x8000000,0x0,0xc000000,0x0,0x0,0x8000000,0x8000000,0x0,0x8000000,0x0,0x0,0x0,0x0,0x0,0x8000000,0x98f8000,0x8000000,0x8000000,0x0,0x0,0x2000000,0x8800000,0xe0000000,0xe0000000,0x0,0x0,0x0,0x8000000,0x8000000,0x0,0x8000000,0x8000000,0x0,0x6000,0x0,0x8000000,0x8000000,0x1fff,0x8000000,0xc000000,0xc000000,0x8000000,};
   }
   private static void jj_la1_3() {
      jj_la1_3 = new int[] {0x0,0x100,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x100,0x0,0x80,0x80,0x100,0x0,0x40,0x40,0x100,0x40,0x1c0,0x0,0x0,0x100,0x0,0x40,0x0,0x40,0x0,0x0,0x1c0,0x100,0x0,0x1,0x1,0x0,0x1c0,0x1c0,0x42,0x42,0x0,0x40,0x42,0x20,0x0,0x0,0x40,0x40,0x0,0x40,0x80,0x80,0x0,};
   }
  final private JJCalls[] jj_2_rtns = new JJCalls[2];
  private boolean jj_rescan = false;
  private int jj_gc = 0;

  public CLangParser(java.io.InputStream stream) {
     this(stream, null);
  }
  public CLangParser(java.io.InputStream stream, String encoding) {
    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new CLangParserTokenManager(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(java.io.InputStream stream) {
     ReInit(stream);
  }
  public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public CLangParser(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new CLangParserTokenManager(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public CLangParser(CLangParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  public void ReInit(CLangParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 53; i++) jj_la1[i] = -1;
    for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
  }

  final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken = token;
    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
    else jj_nt = jj_nt.next = token_source.getNextToken();
    if (token.kind == kind) {
      jj_gen++;
      if (++jj_gc > 100) {
        jj_gc = 0;
        for (int i = 0; i < jj_2_rtns.length; i++) {
          JJCalls c = jj_2_rtns[i];
          while (c != null) {
            if (c.gen < jj_gen) c.first = null;
            c = c.next;
          }
        }
      }
      return token;
    }
    jj_nt = token;
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  static private final class LookaheadSuccess extends java.lang.Error { }
  final private LookaheadSuccess jj_ls = new LookaheadSuccess();
  final private boolean jj_scan_token(int kind) {
    if (jj_scanpos == jj_lastpos) {
      jj_la--;
      if (jj_scanpos.next == null) {
        jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
      } else {
        jj_lastpos = jj_scanpos = jj_scanpos.next;
      }
    } else {
      jj_scanpos = jj_scanpos.next;
    }
    if (jj_rescan) {
      int i = 0; Token tok = token;
      while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
      if (tok != null) jj_add_error_token(kind, i);
    }
    if (jj_scanpos.kind != kind) return true;
    if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
    return false;
  }

  final public Token getNextToken() {
    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
    else jj_nt = jj_nt.next = token_source.getNextToken();
    jj_gen++;
    return token;
  }

  final public Token getToken(int index) {
    Token t = lookingAhead ? jj_scanpos : token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  private java.util.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;
  private int[] jj_lasttokens = new int[100];
  private int jj_endpos;

  private void jj_add_error_token(int kind, int pos) {
    if (pos >= 100) return;
    if (pos == jj_endpos + 1) {
      jj_lasttokens[jj_endpos++] = kind;
    } else if (jj_endpos != 0) {
      jj_expentry = new int[jj_endpos];
      for (int i = 0; i < jj_endpos; i++) {
        jj_expentry[i] = jj_lasttokens[i];
      }
      boolean exists = false;
      for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
        int[] oldentry = (int[])(e.nextElement());
        if (oldentry.length == jj_expentry.length) {
          exists = true;
          for (int i = 0; i < jj_expentry.length; i++) {
            if (oldentry[i] != jj_expentry[i]) {
              exists = false;
              break;
            }
          }
          if (exists) break;
        }
      }
      if (!exists) jj_expentries.addElement(jj_expentry);
      if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
    }
  }

  public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[107];
    for (int i = 0; i < 107; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 53; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
          if ((jj_la1_2[i] & (1<<j)) != 0) {
            la1tokens[64+j] = true;
          }
          if ((jj_la1_3[i] & (1<<j)) != 0) {
            la1tokens[96+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 107; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    jj_endpos = 0;
    jj_rescan_token();
    jj_add_error_token(0, 0);
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

  final private void jj_rescan_token() {
    jj_rescan = true;
    for (int i = 0; i < 2; i++) {
    try {
      JJCalls p = jj_2_rtns[i];
      do {
        if (p.gen > jj_gen) {
          jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
          switch (i) {
            case 0: jj_3_1(); break;
            case 1: jj_3_2(); break;
          }
        }
        p = p.next;
      } while (p != null);
      } catch(LookaheadSuccess ls) { }
    }
    jj_rescan = false;
  }

  final private void jj_save(int index, int xla) {
    JJCalls p = jj_2_rtns[index];
    while (p.gen > jj_gen) {
      if (p.next == null) { p = p.next = new JJCalls(); break; }
      p = p.next;
    }
    p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
  }

  static final class JJCalls {
    int gen;
    Token first;
    int arg;
    JJCalls next;
  }

}
